﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chunker
{
    [Serializable]
    public class Chunk : IChunk
    {
        /// <summary>
        /// Content hash
        /// </summary>
        public string Hash { get; set; }

        /// <summary>
        /// Content of the file block
        /// </summary>
        public virtual byte[] Content { get; set; }

        public long Start { get; set; }

        public long End { get; set; }

        /// <summary>
        /// Number of times that the chunk repeats
        /// </summary>
        public long Count { get; set; }

        public override string ToString()
        {
            return string.Format( "[{0}, {1}]", this.Content.Length, Hash );
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override bool Equals( object obj )
        {
            if ( !( obj is Chunk ) ) {
                return false;
            }

            return ( obj as Chunk ).Hash.Equals( this.Hash );
        }
    }
}
